/*
 * @Author: szx
 * @Date: 2022-06-02 16:50:25
 * @LastEditTime: 2022-06-02 17:35:40
 * @Description:
 * @FilePath: \leetcode\400-499\468\468.js
 */
var validIPAddress = (queryIP) => (queryIP.match(/^((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)($|(?!\.$)\.)){4}$/) ? 'IPv4' : queryIP.match(/^(([\da-fA-F]{1,4})($|(?!:$):)){8}$/) ? 'IPv6' : 'Neither');

/**
 * @param {string} queryIP
 * @return {string}
 */
var validIPAddress = function (queryIP) {
    // /^(([\da-fA-F]{1,4})($|(?!:$):)){8}$/
    // /^((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)($|(?!\.$)\.)){4}$/
    const ipv4 = /^(25[0-5]|2[0-4]\d|[01]?\d{1,2}\.){3}(25[0-5]|2[0-4]\d|[01]?\d{1,2})$/;
    const ipv6 = /^([\da-fA-F]{1,4}:){7}([\da-fA-F]{1,4}:)$/;
    return ipv4.test(queryIP) ? 'IPv4' : ipv6.test(queryIP) ? 'IPv6' : 'Neither';
};
let quit = 'qu';
let noquit = 'qt';
let quRegex = /q(?=u)/;
let qRegex = /q(?!u)/;
console.log(quRegex.exec(quit));
console.log(qRegex.exec(noquit));
